﻿param($computers,$computersListFilePath)

if($computers -eq $null -and $computersListFilePath -ne $null)
{
    $computers=Get-Content $computersListFilePath
}

$totalComputers=$computers.Count
$monitoredComputers=0

foreach($computer in $computers)
{
    $computerName=$computer.Replace(" ","")

    if(Test-Connection -ComputerName $computerName -Count 1 -ErrorAction SilentlyContinue)
    {
        Write-Host "Starting services on "$computerName
        Get-Service -Name RemoteRegistry -ComputerName $computerName | Set-Service -Status Running
        Get-Service -Name pla -ComputerName $computerName | Set-Service -Status Running
        Get-Service -Name RemoteRegistry -ComputerName $computerName
        Get-Service -Name pla -ComputerName $computerName
        $monitoredComputers++
    }
    else
    {
        Write-Host "$computerName is not pinging, skipping."
    }
}

Write-Host "$monitoredComputers computers monitored on $totalComputers"


